package uk.co.drpj.rep;

import java.util.Hashtable;


public class PhraseAt implements Comparable {

	private int             voiceId;
	double                     time;
	PulseSequence            timing;
	Hashtable<String,Map> sequences;
	MapSequence                 map;
	private double len;

	
	/**
	 * 
	 * Construct a phrase assuming pitch is semitone scale.
	 * 
	 * @param timing
	 * @param seqPitch
	 * @param seqVel
	 */
	public PhraseAt(int voiceId,double time,
			PulseSequence timing, 
			int[] seqPitch,
			int[] seqVel,
			MapSequence map,
			double len) {
		super();
		assert(map != null);
		this.voiceId=voiceId;
		this.time=time;
		this.timing = timing;
		this.map=map;
		this.len=len;
		this.sequences=new Hashtable<String,Map>();
		sequences.put("pitch",new ArrayMap(seqPitch));
		sequences.put("vel",new ArrayMap(seqVel));
	}

	public Map getSeq(String name) {
		return sequences.get(name);
	}

	
	public void putSeq(String name,Map map) {
		sequences.put(name,map);
	}

	public PulseSequence getTiming() {
		return timing;
	}

	public void setTiming(PulseSequence timing) {
		this.timing = timing;
	}

	public double getTime() {
		return time;
	}

	public void setTime(double time) {
		this.time = time;
	}

	public int compareTo(Object o) {	
		return Double.compare(time,((PhraseAt)o).time);
	}

	public MapSequence getMapSequence() {
		return map;
	}

	public double getLength() {
		return len;
	}

	public void setMapSequence(TreeMapSequence newMapSeq) {
			map=newMapSeq;
	}


	
	
}
